#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
using namespace std;
int s[1010][20], t[10];
int cnt;
int main()
{
	int n;
	cin >> n;
	int a, b, c, d, e, f, g;
	cin >> a >> b >> c >> d >> e >> f >> g;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < 7; j++)
			cin >> s[i][j];

	for (int i = 0; i < n; i++)
	{
		cnt = 0;
		for (int j = 0; j < 7; j++)
		{
			if (s[i][j] == a || s[i][j] == b || s[i][j] == c || s[i][j] == d || s[i][j] == e || s[i][j] == f || s[i][j] == g)
				cnt++;
		}
		if (cnt == 7) t[0]++;
		else if (cnt == 6) t[1]++;
		else if (cnt == 5) t[2]++;
		else if (cnt == 4) t[3]++;
		else if (cnt == 3) t[4]++;
		else if (cnt == 2) t[5]++;
		else if (cnt == 1) t[6]++;
	}
	for (int i = 0; i < 7; i++)
		cout << t[i] << " ";
	cout << endl;
	return 0;
}